package model;

import java.util.Observer;


public class WorksheetModel_dep {
	
	private Cell_dep[][] sheet;
	
	public WorksheetModel_dep(int _numRows, int _numColumns) {
		sheet = new Cell_dep[_numRows][_numColumns];
		
		for (int i = 0; i < _numRows; i++) {
			for (int j = 0; j < _numColumns; j++) {
				sheet[i][j] = new Cell_dep(i, j, this);
			}
		}
	}
	
	public void addObserver(Observer[][] observadores) {
		for (int i = 0; i < observadores.length; i++) {
			for (int j = 0; j < observadores[i].length; j++) {
				this.sheet[i][j].addObserver(observadores[i][j]);
			}
		}
	}
	
	public String getCellValue(int abscissa, int ordinate) throws Exception {
		return getCell(abscissa, ordinate).getValue();
	}
	
	public Cell_dep getCell(int abscissa, int ordinate) {
		return sheet[abscissa][ordinate];
	}
	
	public String work (int xx, int yy, String value) throws NumberFormatException, Exception {
		
		Cell_dep c = sheet[xx][yy];
		//Actualizar o modelo
		c.setValue(value);
		return c.doMagik();
		
	}	
	
}
